local BaseState = require("states.gen.base_state")

return Class{
   __includes = BaseState,
   init = function (self, name)
      BaseState.init(self)
   end,

   make_menu = function (self)
      local x, y, w, h = self.gui:center(400, 126)
      local ul
      if not Game.current_map then
	 ul = self.gui:ul(x, y, w, h, "Skirmish", "Units", "Options", "Quit")
	 ul.onclick = function (index, b)
	    _match(index, {
		      { 1, function () Game:switch_state ("map_view") end },
		      { 2, function () Game:switch_state ("unit_view") end },
		      { 3, function () Game:switch_state ("options") end },
		      { 4, love.event.quit }
	    })
	 end
      else
	 ul = self.gui:ul(x, y, w, h+30, "Resume", "Skirmish", "Units", "Options", "Quit")
	 ul.onclick = function (index, b)
	    _match(index, {
		      { 1, function () Game:switch_state ("deployment", true) end },
		      { 2, function () Game:switch_state ("map_view") end },
		      { 3, function () Game:switch_state ("unit_view") end },
		      { 4, function () Game:switch_state ("options") end },
		      { 5, love.event.quit }
	    })
	 end
      end
      return ul
   end,
   
   load = function (self)
      self.gui:reset()
      self.ul = self:make_menu()
   end,
}
